how recursion works internally